package com.azure.code.timecomplexity;

/**
 * 时间复杂度分析
 * O(1)     常数阶
 * O(n)     线性阶
 * O(n^2)   平方阶
 * O(logN)  对数阶
 * O(nlogN) 线性的对数阶
 * O(n^3)   立方阶
 * O(2^n)   指数阶
 * O(n!)    阶乘阶
 *
 * O(1) < O(logN) < O(n) < O(nlogN) < O(n^2) < O(n^3) < O(2^n) < O(n!) < O(n^n)
 *
 */
public class StudyDemo {

    int cal3(int n) {
        int sum_1 = 0;
        for (int i = 0; i < 100; i++) {
            sum_1 = sum_1 + i;
        }

        int sum_2 = 0;
        for (int i = 0; i < n; i++) {
            sum_2 = sum_2 + i;
        }

        int sum_3 = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                sum_3 = sum_3 + i * j;
            }
        }
        return sum_1 + sum_2 + sum_3;
    }
}
